import request from "@/utils/request.ts";
import type { ResponseType } from "@/types/responseTypes";
import type { Address } from "@/types/addressTypes";

enum Enum {
    addressList = "/patient/order/address",
    addAddress = "/patient/order/address",
    deleteAddress = "/patient/order/address",
    addressDetail = "/patient/order/address",
    editAddress="/patient/order/address"
}

/*获取收货地址列表的接口*/
export const fetchAddressListAPI = (): Promise<ResponseType<Address[]>> => request.get<Address, ResponseType<Address[]>>(Enum.addressList);
/*添加收货地址的接口*/
export const addAddressAPI = (data: Address): Promise<ResponseType<{ data: string }>> => request.post<{ data: string }, ResponseType<{ data: string }>>(Enum.addAddress, data);
/*删除收货地址的接口*/
export const deleteAddressAPI = (addressId: string): Promise<ResponseType<{ id: string }>> => request.delete<{ id: string }, ResponseType<{ id: string }>>(`${Enum.deleteAddress}/${addressId}`);
/*获取收货地址详情的接口*/
export const findAddressDetailAPI = (addressId: string): Promise<ResponseType<Address>> => request.get<Address, ResponseType<Address>>(`${Enum.addressDetail}/${addressId}`);
/*修改收货地址的接口*/
export const editAddressAPI=(addressId:string,data:Address): Promise<ResponseType<{ id: string }>> =>request.put<{id:string},ResponseType<{ id:string }>>(`${Enum.editAddress}/${addressId}`,data)
